package com.example.springstatemachine.controller;

import com.example.springstatemachine.service.DocumentService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

@RestController
@RequestMapping("/document")
public class DocumentController {

    private final DocumentService documentService;

    @Autowired
    public DocumentController(DocumentService documentService) {
        this.documentService = documentService;
    }

    @PostMapping("/submit/{documentId}/{userId}")
    public String submitDocument(@PathVariable Long documentId, @PathVariable Long userId) {
        return documentService.submitDocument(documentId, userId);
    }

    @PostMapping("/approve/{documentId}/{userId}")
    public String approveDocument(@PathVariable Long documentId, @PathVariable Long userId) {
        return documentService.approveDocument(documentId, userId);
    }

    @PostMapping("/reject/{documentId}/{userId}")
    public String rejectDocument(@PathVariable Long documentId, @PathVariable Long userId) {
        return documentService.rejectDocument(documentId, userId);
    }

    @PostMapping("/publish/{documentId}/{userId}")
    public String publishDocument(@PathVariable Long documentId, @PathVariable Long userId) {
        return documentService.publishDocument(documentId, userId);
    }
}